I made this function to remove rows being looped into in a spec table view when all the cells in that row contain "N/A" instead of a spec. For reasons not worth going into, I need to change my table view from an HTML table to a fake table (html grid) with nested divs. This means that the specs are no longer connected by the tr tag, so I'm not sure how I can connect them to accomplish the same result...
$('.specnacheckrow').each(function() { // for each row in the table
var naTrue = 0;
var totalCells = 0;
var $this = $(this);
totalCells = $this.find('.specnacheckcell').length //count how many cells
naTrue = $this.find('.specnatrue').length //count how many <span class="specnatrue">N/A</span>
if (naTrue < totalCells) { //if the number of cells is greater than the number of N/A's
$this.show(); //show the row
} else {
$this.remove(); //else, hide the entire row - this includes the spec label at the beginning of the row.
}
});
Example of original table - https://codepen.io/genopeppino/pen/PojMero
Example of Grid Divs - https://codepen.io/genopeppino/pen/oNwKyNJ
You can see that in the original table the "Ship Weight - KG" row is correctly removed by the function above.